<!DOCTYPE html>
<html lang="en">

	<head>
		<meta charset="UTF-8">
		<meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no">
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">
		<meta name="format-detection" content="telephone=no">
		<title>无忧微贷</title>
		<link rel="stylesheet" type="text/css" href="../css/reset.css">
		<link rel="stylesheet" type="text/css" href="../css/common.css">
		<link rel="stylesheet" type="text/css" href="../css/icomoon/style.css">
		<script type="text/javascript" src="../js/rem.js"></script>
	</head>
    <style>
    	.wrapper{ position: absolute; width: 100%; top: 2.2rem; bottom: 0;}
    </style>
	<body onload="loaded()">
		<div id="content">
			<h3 class="header f-pr">
				<span>项目详情</span>
				<i class="icon-angle-left f-pa"></i>
			</h3>
			<div class="m-borrow">
				<div class="borrow-tabs clearfix">
					<a href="javascript:;" class="tab active" data-id="1"><span>借款明细</span></a>
					<a href="javascript:;" class="tab" data-id="2"><span>借款人</span></a>
					<a href="javascript:;" class="tab" data-id="3"><span>投标记录</span></a>
				</div>
				<div id="wrapper" class="wrapper">
					<div id="scroller">
						<div class="bid-info" id="borrow-detail">
							<div class="info info1">
								<h3>
									<i class="line"></i>
									<span id="credit_name"></span>
								</h3>
								<h3>
									<i class="line"></i>
									<span>借款描述</span>
								</h3>
								<div id="borrow_desc" style="font-size: 0.26rem;"></div>
							</div>
							<div class="info info2">
								<h3>
									<i class="line"></i>
									<span>风控措施</span>
								</h3>
								<div id="risk_desc" style="font-size: 0.26rem;"></div>
							</div>
						</div>
						<div class="bid-info" id="borrow-info" style="display: none;">
							<div class="info info-1">
								<h3>
									<i class="line"></i>
									<span>借款方基础信息</span>
								</h3>
								<div class="userinfo">
									<div class="item">
										<label>用户名</label>
										<p id="account">10000011235</p>
									</div>
									<div class="item">
										<label>注册时间</label>
										<p id="register_date">2017-03-23</p>
									</div>
								</div>
							</div>
							<!--<div class="info info-3">
								<h3>
									<i class="line"></i>
									<span>借款记录</span>
								</h3>
								<div class="borrow-record">
									<div class="item clearfix">
										<label>成功借款</label>
										<p class="f-fr" id="borrow_total"></p>
									</div>
									<div class="item clearfix">
										<label>还款笔数</label>
										<p class="f-fr" id="repayment_count"></p>
									</div>
									<div class="item clearfix">
										<label>逾期未还</label>
										<p class="f-fr" id="overdue_count"></p>
									</div>
								</div>
							</div>-->
							<div class="info info-2">
								<h3>
									<i class="line"></i>
									<span>证件信息</span>
								</h3>
								<ul class="photos clearfix" id="photos"></ul>
							</div>
						</div>
						<div id="bidlist" style="display: none;">
							<ul class="bid-record"></ul>
							<div class="nodata nodata-1 hide">
								<p class="img"><img src="../images/nodata-1.png"></p>
								<p class="text">暂无数据</p>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
		<script type="text/javascript" src="../js/md5.min.js"></script>
		<script type="text/javascript" src="../js/zepto.min.js"></script>
		<script type="text/javascript" src="../js/mui.min.js"></script>	
		<script type="text/javascript" src="../js/iscroll.js"></script>
		<script type="text/javascript" src="../js/scroller.js"></script>
		<script type="text/javascript" src="../js/common.js"></script>
		<script type="text/javascript">
			mui.plusReady(function() {
				var data_id = plus.webview.currentWebview().data_id;
				if(data_id == 1) {
					$('.borrow-tabs .tab:nth-child(1)').addClass('active').siblings('.tab').removeClass('active');
					$('#borrow-detail').show();
					$('#borrow-info, #bidlist').hide();
				} else if(data_id == 2) {
					$('.borrow-tabs .tab:nth-child(2)').addClass('active').siblings('.tab').removeClass('active');
					$('#borrow-info').show();
					$('#borrow-detail, #bidlist').hide();
				} else if(data_id == 3) {
					$('.borrow-tabs .tab:nth-child(3)').addClass('active').siblings('.tab').removeClass('active');
					$('#bidlist').show();
					$('#borrow-detail, #borrow-info').hide();
				}

				var borrow = {
					init: function() {
						this.borrowDetail();
						this.getImages();
						this.getInfo();
						this.bidList();
					},

					borrowDetail: function() {
						mui.ajax(base + 'credit/remark', {
							type: 'get',
							data: {
								'credit': plus.webview.currentWebview().credit
							},
							dataType: 'json',
							headers: sign(md5),
							success: function(data) {
								$('#borrow_desc').html(data.borrow_desc);
								$('#credit_name').html(data.credit_name + '简介');
								$('#repayment_desc').html(data.repayment_desc);
								$('#risk_desc').html(data.risk_desc);
							},
							error: function(data) {
								console.error(data.message);
							}
						})
					},

					getImages: function() {
						mui.ajax(base + 'credit/imagedetail', {
							type: 'get',
							data: {
								'credit': plus.webview.currentWebview().credit
							},
							dataType: 'json',
							headers: sign(md5),
							success: function(data) {
								var list = data.list;
								var result = '';
								for(var i = 0, len = list.length; i < len; i++) {
									result += '<li><img src="' + list[i].url + '"></li>';
								}
								$('#photos').html(result);
								$('#photos li').on('tap', function(){
									mui.openWindow({
										url: 'photo.html',
										extras: {
											credit: plus.webview.currentWebview().credit
										},
										show: {
											aniShow: 'pop-in', //页面显示动画，默认为”slide-in-right“；
											event: "loaded"
										}
									});
								});
							},
							error: function() {
								console.error('error');
							}
						});
					},

					getInfo: function() {
						mui.ajax(base + 'credit/borrow', {
							type: 'get',
							data: {
								'credit': plus.webview.currentWebview().credit
							},
							dataType: 'json',
							headers: sign(md5),
							success: function(data) {
								$('#account').text(data.account);
								$('#register_date').text(data.regiester_date);
								$('#overdue_count').text(data.overdue_count + '笔');
								$('#repayment_count').text(data.repayment_count + '笔');
								$('#borrow_total').text(data.borrow_total + '笔');
							},
							error: function(data) {
								console.info(data.message);
							}
						});
					},

					bidList: function() {
						mui.ajax(base + 'credit/bidlist', {
							type: 'get',
							data: {
								'credit': plus.webview.currentWebview().credit
							},
							dataType: 'json',
							headers: sign(md5),
							success: function(data) {
								var result = '', list = data.list;
								if(list.length > 0){
									for(var i = 0, len = list.length; i < len; i++) {
										result += '<li>';
										result += '<p class="f-fl">';
										result += '<span class="name">' + list[i].name + '</span>';
										result += '<span class="time">' + list[i].time + '</span>';
										result += '</p>';
										result += '<p class="f-fr"><span class="amount">' + list[i].amount + '</span>元</p>';
										result += '</li>';
									}
									$('#bidlist ul').html(result);
								}else{
									$('#bidlist .nodata').removeClass('hide');
								}
							},
							error: function() {
								console.error('error');
							}
						});
					}
				};

				borrow.init();
				$('.borrow-tabs .tab').on('tap', function() {
					var that = $(this),
						id = parseInt($(this).attr('data-id'));
					if(!(that.hasClass('active'))) {
						that.addClass('active').siblings('.tab').removeClass('active');
						if(id == 1) {
							$('#borrow-detail').show();
							$('#borrow-info, #bidlist').hide();
						} else if(id == 2) {
							$('#borrow-info').show();
							$('#borrow-detail, #bidlist').hide();
						} else if(id == 3) {
							$('#bidlist').show();
							$('#borrow-detail, #borrow-info').hide();
						}
					}
				});
				
				$('.icon-angle-left').on('tap', function(){
					mui.back();
				});
			});
		</script>
	</body>

</html>